<include file="Public:head" />
<link href="__APP__/Application/{$Think.MODULE_NAME}/Public/css/gifts.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
    $(function(){
        //$(".top_NewNava").children().eq(2).addClass("active").siblings("li").removeClass("active");

        var awardList=[$('#award1'),$('#award2'),$('#award3'),$('#award4'),$('#award5'),$('#award6'),$('#award7'),$('#award8')]
        ,nowIndex=1,si,is_stop = 1,stopAward,nowIndex2;
       
        function nextAwar(){
             $(awardList[nowIndex-1]).removeClass('active');
            nowIndex=(nowIndex+1)>8?1:nowIndex+1;
            $(awardList[nowIndex-1]).addClass('active');
            is_stop = 0;
        }
        function stopAwardFunc(){
            $(awardList[nowIndex-1]).removeClass('active');
            nowIndex=(nowIndex+1)>8?1:nowIndex+1;
            $(awardList[nowIndex-1]).addClass('active');
            var id = $('.tag_image').attr("awardId");
            if($(".left_content .active").hasClass("item_"+id+"")){
                clearInterval(stopAward);
                var points = parseInt($(".left_content .active").attr("data-points"));
                if(points>0){
                    moveTO($(".left_content .active"),points);
                }else{
                    $(".my_point em").html(parseInt($(".my_point em").html())-200);
                    showTip('系统提示',"恭喜您获得"+$('.tag_image').attr("awardTitle")+",奖品会在一个星期内寄送！",'1');
                }
                return false;
            }
        }
        function moveTO(thisO,num){
            var startX=thisO.offset().left+75,startY=thisO.offset().top+75,
            endX=$(".my_point em").offset().left,
            endY=$(".my_point em").offset().top;
            $('<span id="add_num" style="font-size:30px;color:#BF4904;">+'+num+'积分</span>').css({
                'position':'absolute','left':startX,'top':startY}).appendTo($('body'));
            $('#add_num').animate({left:endX+'px',top:endY+'px',opacity:'0.4',fontSize:'14px'},1500,function(){
                $('#add_num').remove();$(".my_point em").html(parseInt($(".my_point em").html())+num-200);});
        }
       
        $('.do_draw').click(function(){
            if(is_stop == 1){
                $.post("{:U('Ajax/award')}",{
                },function(data){
                    if(data.state == -1){
                        var url = "{:U('Login/index')}";
                        goUrl(url);
                    }else if(data.state == -2){
                        showTip('系统提示',"亲，积分不够！",'2',1.5);
                    }else{
                        $('.tag_image').attr("awardId",data.id);
                        $('.tag_image').attr("awardTitle",data.title);
                        si=setInterval(nextAwar,100);
                        setTimeout(function(){
                            
                            clearInterval(si);
                            is_stop = 1;
                            stopAward=setInterval(stopAwardFunc,100);
                            setTimeout(function(){
                                clearInterval(stopAward);
                            },1000);
                            
                        
                        },3000);
                    }
                },"json")
            }
        });
        
    })    
</script>
<div class="draw">
    <div id="school">
        {$type=0|getAreaName} 
        <a href="__APP__/?type=clean">[切换位置]</a>
        <span>/</span>
        <a href="{:U('Gifts/index')}">积分商城</a>
        <span>/</span>
        <em>积分抽奖</em>
    </div>
    <div class="clearfix border_1px">
        <div class="draw_left">
            <div class="left_inner">
                <div class="left_inner_title" >
                    {$config.title}积分抽大奖
<!--                    <img src="__PUBLIC__/images/left_inner_title_img.png" alt="" />-->
                </div>
                <div class="left_content clearfix">
                    <div class="left_content_item item_{$lists[0]['id']}" id="award8" data-points="{$lists[0]['pointsAward']}">
                        <img src="__APP__/{$lists[0]['pic']}" alt="" class="award_pic" />
                        <div class="award_shade award_shade_type1">&nbsp;</div>
                        <div class="award_message award_message_type1">{$lists[0]['title']}</div>
                    </div>
                    <div class="left_content_item active item_{$lists[1]['id']}" id="award1" data-points="{$lists[1]['pointsAward']}">
                        <img src="__APP__/{$lists[1]['pic']}" alt="" class="award_pic" />
                        <div class="award_shade award_shade_type2">&nbsp;</div>
                        <div class="award_message award_message_type2">{$lists[1]['title']}</div>
                    </div>
                    <div class="left_content_item item_{$lists[2]['id']}" id="award2" data-points="{$lists[2]['pointsAward']}">
                        <img src="__APP__/{$lists[2]['pic']}" alt="" class="award_pic" />
                        <div class="award_shade award_shade_type3">&nbsp;</div>
                        <div class="award_message award_message_type3">{$lists[2]['title']}</div>
                    </div>
                    <div class="left_content_item item_{$lists[7]['id']}" id="award7" data-points="{$lists[7]['pointsAward']}">
                        <img src="__APP__/{$lists[7]['pic']}" alt="" class="award_pic" />
                        <div class="award_shade award_shade_type4">&nbsp;</div>
                        <div class="award_message award_message_type2">{$lists[7]['title']}</div>
                    </div>
                    <a class="do_draw"></a>
                    <div class="left_content_item item_{$lists[3]['id']}" id="award3" data-points="{$lists[3]['pointsAward']}">
                        <img src="__APP__/{$lists[3]['pic']}" alt="" class="award_pic" />
                        <div class="award_shade award_shade_type1">&nbsp;</div>
                        <div class="award_message award_message_type1">{$lists[3]['title']}</div>
                    </div>
                    <div class="left_content_item item_{$lists[6]['id']}" id="award6" data-points="{$lists[6]['pointsAward']}">
                        <img src="__APP__/{$lists[6]['pic']}" alt="" class="award_pic" />
                        <div class="award_shade award_shade_type5">&nbsp;</div>
                        <div class="award_message award_message_type1">{$lists[6]['title']}</div>
                    </div>
                    <div class="left_content_item item_{$lists[5]['id']}" id="award5" data-points="{$lists[5]['pointsAward']}">
                        <img src="__APP__/{$lists[5]['pic']}" alt="" class="award_pic" />
                        <div class="award_shade award_shade_type3">&nbsp;</div>
                        <div class="award_message award_message_type3">{$lists[5]['title']}</div>
                    </div>
                    <div class="left_content_item item_{$lists[4]['id']}" id="award4" data-points="{$lists[4]['pointsAward']}">
                        <img src="__APP__/{$lists[4]['pic']}" alt="" class="award_pic" />
                        <div class="award_shade award_shade_type2">&nbsp;</div>
                        <div class="award_message award_message_type2">{$lists[4]['title']}</div>
                    </div>
                </div>
            </div>
        </div>
        <div class="draw_right">
            <img src="__APP__/Application/{$Think.MODULE_NAME}/Public/images/draw_tag.png" alt="" class="tag_image" />
            <p class="draw_rule">1.点击左侧中间圆形大按钮开始抽奖 </p>
            <p class="draw_rule"> 2.每次抽奖将消耗200积分</p>
            <if condition="$user neq ''">
                <h2 class="my_point">
                    我的积分：<em>{$user.money}</em>
                </h2>
            </if>
            <div class="award_list">
                <h2>一等奖</h2>
                <foreach name="lists" item="row">
                   <if condition="$row.rank eq 1"> 
                <p>{$row.bigtitle}</p>
                </if>
                </foreach>
            </div>
            <div class="award_list">
                <h2>二等奖</h2>
                 <foreach name="lists" item="row">
                   <if condition="$row.rank eq 2"> 
                <p>{$row.bigtitle}</p>
                </if>
                </foreach>
            </div>
            <div class="award_list">
                <h2>三等奖</h2>
                 <foreach name="lists" item="row">
                   
                <p>{$row.bigtitle}</p>
               
                </foreach>
            </div>
            <div class="winning_message" id="winning_message1">
                <h3>抽奖结果：祝您下次中奖！:-)</h3>
            </div>
            <div class="winning_message" id="winning_message2">
                <h2>恭喜您抽中二等奖！！</h2>
                <p>奖品：Macbook一台</p>
                <p>请拨电话010-61772988兑换奖品</p>
            </div>
        </div>
    </div>
</div>

<include file="Public:foot" />